CREATE TABLE [dbo].[TCFECH_PROC]
(
[CO_EMPR] [dbo].[TD_VC_002] NOT NULL,
[NU_CNTB_EMPR] [dbo].[TD_IN_001_CONT] NOT NULL,
[CO_UNID_CNTB] [dbo].[TD_VC_003] NOT NULL,
[CO_OPRC_CNTB] [dbo].[TD_VC_003] NOT NULL,
[NU_ANNO] [dbo].[TD_IN_004_ANNO] NOT NULL CONSTRAINT [DF__TCFECH_PR__NU_AN__47DBAE45] DEFAULT (datepart(year,getdate())),
[NU_MESE] [dbo].[TD_IN_002_MESE] NOT NULL,
[NU_ULTI_ASTO] [int] NOT NULL,
[ST_CIER_CNTB] [dbo].[TD_VC_001_SINO] NOT NULL CONSTRAINT [DF__TCFECH_PR__ST_CI__4AB81AF0] DEFAULT ('N'),
[FE_CIER_CNTB] [dbo].[TD_DT_001] NULL,
[ST_MAYO_CNTB] [dbo].[TD_VC_001_SINO] NOT NULL CONSTRAINT [DF__TCFECH_PR__ST_MA__4CA06362] DEFAULT ('N'),
[FE_MAYO_CNTB] [dbo].[TD_DT_001] NULL,
[CO_USUA_CREA] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_CREA] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TCFECH_PR__FE_US__4E88ABD4] DEFAULT (getdate()),
[CO_USUA_MODI] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_MODI] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TCFECH_PR__FE_US__4F7CD00D] DEFAULT (getdate())
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TCFECH_PROC] ADD CONSTRAINT [CK__TCFECH_PR__NU_AN__48CFD27E] CHECK (([NU_ANNO]>=(0)))
GO
ALTER TABLE [dbo].[TCFECH_PROC] ADD CONSTRAINT [CK__TCFECH_PR__NU_CN__46E78A0C] CHECK (([NU_CNTB_EMPR]>=(1) AND [NU_CNTB_EMPR]<=(99)))
GO
ALTER TABLE [dbo].[TCFECH_PROC] ADD CONSTRAINT [CK__TCFECH_PR__NU_ME__49C3F6B7] CHECK (([NU_MESE]>=(0) AND [NU_MESE]<=(13)))
GO
ALTER TABLE [dbo].[TCFECH_PROC] ADD CONSTRAINT [CK__TCFECH_PR__ST_CI__4BAC3F29] CHECK (([ST_CIER_CNTB]='N' OR [ST_CIER_CNTB]='S'))
GO
ALTER TABLE [dbo].[TCFECH_PROC] ADD CONSTRAINT [CK__TCFECH_PR__ST_MA__4D94879B] CHECK (([ST_MAYO_CNTB]='N' OR [ST_MAYO_CNTB]='S'))
GO
ALTER TABLE [dbo].[TCFECH_PROC] ADD CONSTRAINT [TCFECH_PRO_21002025321] PRIMARY KEY CLUSTERED  ([CO_EMPR], [NU_CNTB_EMPR], [CO_UNID_CNTB], [CO_OPRC_CNTB], [NU_ANNO], [NU_MESE]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TCFECH_PROC] ADD CONSTRAINT [FK1_TMOPRC_CNTB_A_TCFECH_PROC] FOREIGN KEY ([CO_EMPR], [CO_OPRC_CNTB]) REFERENCES [dbo].[TMOPRC_CNTB] ([CO_EMPR], [CO_OPRC_CNTB])
GO
ALTER TABLE [dbo].[TCFECH_PROC] ADD CONSTRAINT [FK1_TTCNTB_EMPR_A_TCFECH_PROC] FOREIGN KEY ([CO_EMPR], [NU_CNTB_EMPR]) REFERENCES [dbo].[TTCNTB_EMPR] ([CO_EMPR], [NU_CNTB_EMPR])
GO
